<template>
	<BasicModal v-bind="$attrs" z-index="1000" style="z-index:999" @register="registerModal" title="请选择标签"
		@ok="confirmUpdateRole">
		<BasicForm @register="registerForm">

		</BasicForm>
	</BasicModal>
</template>
<script lang="ts" setup>
	import { defineComponent, ref, unref, inject } from 'vue';
	import { updateInviteIdFrom } from '../CoupleUser.data';
	import { updateInviteId } from '../CoupleUser.api';
	import { useMessage } from '/@/hooks/web/useMessage';
	import { BasicForm, useForm } from '/@/components/Form/index';
	import { BasicModal, useModalInner } from '/@/components/Modal';
	const emit = defineEmits(['register', 'success']);

	const $message = useMessage()
	const mainId = inject('mainId') || '';
	const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
		setModalProps({ zIndex: 1000 })
		setFieldsValue({
			id: data.id
		})
	})
	const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
		//labelWidth: 150,
		schemas: updateInviteIdFrom,
		showActionButtonGroup: false,

		baseColProps: { span: 24 },


	});


	async function confirmUpdateRole() {
		let values = await validate();


		if (values.id == values.inviteId) {
			$message.createMessage.warning('上级不能是自己')


			return  //上级不能是自己
		}



		//提交表单
		await updateInviteId(values);
		emit('success');
		closeModal();

	}
</script>

<style>

</style>